'''
用户登录要求
'''
from django.contrib.auth.models import AnonymousUser
from django.shortcuts import redirect
from django.urls import reverse

def is_login(func):
    def wrapper(request, *args, **kwargs):
        # 若检测不到用户就跳转登录页面
        if request.user == AnonymousUser():
            return redirect(reverse('account_login'))
        return func(request, *args, **kwargs)
    return wrapper
